<?php

/**
 * Created by PhpStorm.
 * User: steven
 * Date: 2016/3/25
 * Time: 19:31
 */
class Onduty_Model extends CI_Model
{
    public function __construct()
    {
        $this->load->database();
    }

    public function get_excute_server_list(){
        $this->db->where('is_deleted','N');
        $this->db->where('role',1);
        $result= $this->db->get('duty_table');
        return $result->result();
    }

    public function get_excute_server_by_id($id){
        $this->db->where('id', $id);
        $this->db->where('is_deleted', 'N');
        $result= $this->db->get('duty_table');
        return $result->row();
    }

    public function get_onduty_by_param($param){
        $sql="select * from duty_table where is_deleted='N'";
        if(!empty($param['openid'])){
            $sql= $sql." AND openid='".$param['openid']."'";
        }
        if(!empty($param['user_id'])){
            $sql=$sql." AND user_id='".$param['user_id']."'";
        }
        $query=$this->db->query($sql);
        return $query->result_array();
    }
}